function printExam() {
    let num = prompt('输入考试科目数量')
    if (isNaN(num)) {
        alert('请输入数字')
        return
    }
    if (num <= 0) {
        alert('请输入大于0的数字')
        return
    }
    let sum = 0
    for (let i = 0; i < num; i++) {
        let subject = prompt(`第${i+1}科分数`)
        subject = parseFloat(subject)
        sum += subject
    }

    document.write(`总分数为${sum}`)
}